﻿using DailyPoetryX.Services;
using DailyPoetryX.Services.Implementations;
using GalaSoft.MvvmLight.Ioc;

namespace DailyPoetryX.ViewModels {
    /// <summary>
    /// ViewModel定位器。
    /// </summary>
    public class ViewModelLocator {
        /// <summary>
        /// 菜单页ViewModel。
        /// </summary>
        public MenuPageViewModel MenuPageViewModel =>
            SimpleIoc.Default.GetInstance<MenuPageViewModel>();

        /// <summary>
        /// 初始化页ViewModel。
        /// </summary>
        public InitializationPageViewModel InitializationPageViewModel =>
            SimpleIoc.Default.GetInstance<InitializationPageViewModel>();

        /// <summary>
        /// 今日推荐页ViewModel。
        /// </summary>
        public TodayPageViewModel TodayPageViewModel =>
            SimpleIoc.Default.GetInstance<TodayPageViewModel>();

        /// <summary>
        /// 诗词搜索页ViewModel。
        /// </summary>
        public QueryPageViewModel QueryPageViewModel =>
            SimpleIoc.Default.GetInstance<QueryPageViewModel>();

        /// <summary>
        /// 搜索结果页ViewModel。
        /// </summary>
        public ResultPageViewModel ResultPageViewModel =>
            SimpleIoc.Default.GetInstance<ResultPageViewModel>();

        /// <summary>
        /// 诗词详情页ViewModel。
        /// </summary>
        public DetailPageViewModel DetailPageViewModel =>
            SimpleIoc.Default.GetInstance<DetailPageViewModel>();

        /// <summary>
        /// 我的收藏页ViewModel。
        /// </summary>
        public FavoritePageViewModel FavoritePageViewModel =>
            SimpleIoc.Default.GetInstance<FavoritePageViewModel>();

        /// <summary>
        /// 关于页ViewModel。
        /// </summary>
        public AboutViewModel AboutViewModel =>
            SimpleIoc.Default.GetInstance<AboutViewModel>();

        /// <summary>
        /// 数据同步页ViewModel。
        /// </summary>
        public SyncPageViewModel SyncPageViewModel =>
            SimpleIoc.Default.GetInstance<SyncPageViewModel>();

        /// <summary>
        /// 主页面ViewModel。
        /// </summary>
        public MainPageViewModel MainPageViewModel =>
            SimpleIoc.Default.GetInstance<MainPageViewModel>();

        /// <summary>
        /// ViewModel定位器。
        /// </summary>
        public ViewModelLocator() {
            SimpleIoc.Default.Register<IPreferenceStorage, PreferenceStorage>();
            SimpleIoc.Default.Register<IPoetryStorage, PoetryStorage>();
            SimpleIoc.Default
                .Register<IRootPageActivationService,
                    CachedRootPageActivationService>();
            SimpleIoc.Default
                .Register<IContentPageActivationService,
                    CachedContentPageActivationService>();
            SimpleIoc.Default
                .Register<IRootNavigationService, RootNavigationService>();
            SimpleIoc.Default
                .Register<IContentNavigationService, ContentNavigationService
                >();
            SimpleIoc.Default.Register<MenuPageViewModel>();
            SimpleIoc.Default.Register<InitializationPageViewModel>();

            SimpleIoc.Default.Register<ITodayImageStorage, TodayImageStorage>();
            SimpleIoc.Default.Register<IAlertService, AlertService>();
            SimpleIoc.Default.Register<ITodayImageService, BingImageService>();
            SimpleIoc.Default
                .Register<ITodayPoetryService, JinrishiciService>();
            SimpleIoc.Default.Register<IBrowserService, BrowserService>();
            SimpleIoc.Default.Register<TodayPageViewModel>();

            SimpleIoc.Default.Register<QueryPageViewModel>();
            SimpleIoc.Default.Register<ResultPageViewModel>();

            SimpleIoc.Default.Register<IFavoriteStorage, FavoriteStorage>();
            SimpleIoc.Default.Register<DetailPageViewModel>();

            SimpleIoc.Default.Register<FavoritePageViewModel>();
            SimpleIoc.Default.Register<AboutViewModel>();

            SimpleIoc.Default.Register<OneDriveFavoriteStorage>();
            SimpleIoc.Default.Register<AzureFavoriteStorage>();
            SimpleIoc.Default.Register<SyncPageViewModel>();

            SimpleIoc.Default.Register<MainPageViewModel>();
        }
    }
}